//
//  DZHomeController.m
//  dzyc
//
//  Created by 蓝鳍互娱 on 2024/6/11.
//

#import "DZHomeController.h"
#import "DZSpeedReportController.h"
#import "DZBuyVipController.h"
#import "DZKeTangController.h"
#import "DZReportController.h"
#import "DZRedomNumController.h"
#import "DZMainController.h"
#import "DZGuidePage.h"
@interface DZHomeController ()

@end

@implementation DZHomeController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.hidden = YES;
    [self creatSubView];
    DZWeakSelf
    [[DZGuidePage defaultManager] showGuidePage:^{
        [weakSelf checkVipStatus:^{
            
        }];
    }];
}
- (void)creatSubView{
    UIImageView * dzHomeBgImgView = [[UIImageView alloc] init];
    dzHomeBgImgView.image = DZImageNamed(@"dz_homeBg");
    dzHomeBgImgView.userInteractionEnabled = YES;
    [self.view addSubview:dzHomeBgImgView];
    [dzHomeBgImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(@(DZRatio(0)));
    }];
    UIButton * dzHomeSetBtn = [[UIButton alloc] init];
    [dzHomeSetBtn setBackgroundImage:DZImageNamed(@"dz_homeSetIcon") forState:UIControlStateNormal];
    [dzHomeSetBtn addTarget:self action:@selector(homeSet) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dzHomeSetBtn];
    [dzHomeSetBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(DZRatio(44)));
        make.height.equalTo(@(DZRatio(44)));
        make.right.equalTo(@(-DZRatio(24)));
        make.top.equalTo(@(DZRatio(25)+DZTopSafe_H));
    }];
   
    UIButton * dzHomeRepoprtBtn = [[UIButton alloc] init];
    [dzHomeRepoprtBtn setBackgroundImage:DZImageNamed(@"dz_homeRepoprtSet") forState:UIControlStateNormal];
    [dzHomeRepoprtBtn addTarget:self action:@selector(homeRepoprt) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dzHomeRepoprtBtn];
    [dzHomeRepoprtBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(DZRatio(327)));
        make.height.equalTo(@(DZRatio(388)));
        make.left.equalTo(@(DZRatio(30)));
        make.bottom.equalTo(@(-DZRatio(139)));
    }];
    UIButton * dzHomeRedomNumBtn = [[UIButton alloc] init];
    [dzHomeRedomNumBtn setBackgroundImage:DZImageNamed(@"dz_homeRedomNum") forState:UIControlStateNormal];
    [dzHomeRedomNumBtn addTarget:self action:@selector(homeRedomNum) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dzHomeRedomNumBtn];
    [dzHomeRedomNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(DZRatio(327)));
        make.height.equalTo(@(DZRatio(388)));
        make.right.equalTo(@(-DZRatio(30)));
        make.bottom.equalTo(@(-DZRatio(139)));
    }];
    UIButton * dzHomeSpeedReportBtn = [[UIButton alloc] init];
    [dzHomeSpeedReportBtn setBackgroundImage:DZImageNamed(@"dz_homeSpeedReport") forState:UIControlStateNormal];
    [dzHomeSpeedReportBtn addTarget:self action:@selector(homeSpeedReport) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dzHomeSpeedReportBtn];
    [dzHomeSpeedReportBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(DZRatio(327)));
        make.height.equalTo(@(DZRatio(388)));
        make.left.equalTo(@(DZRatio(30)));
        make.bottom.equalTo(dzHomeRepoprtBtn.mas_top).offset(-DZRatio(36));
    }];
    UIButton * dzHomeKeTangBtn = [[UIButton alloc] init];
    [dzHomeKeTangBtn setBackgroundImage:DZImageNamed(@"dz_homeKeTang") forState:UIControlStateNormal];
    [dzHomeKeTangBtn addTarget:self action:@selector(homeKeTang) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dzHomeKeTangBtn];
    [dzHomeKeTangBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@(DZRatio(327)));
        make.height.equalTo(@(DZRatio(388)));
        make.right.equalTo(@(-DZRatio(30)));
        make.top.equalTo(dzHomeSpeedReportBtn);
    }];
}
- (void)checkVipStatus:(void(^)(void))complick{
    NSTimeInterval buyTime = [NSString getBuyTime];
    NSTimeInterval cureentTime = [NSString getNowTime];
    if(!buyTime||buyTime <= cureentTime){//非会员
        DZBuyVipController * buyVipCtrl = [[DZBuyVipController alloc] init];
        UINavigationController * buyVipNavCtrl = [[UINavigationController alloc] initWithRootViewController:buyVipCtrl];
//        buyVipNavCtrl.navigationBarHidden = YES;
        buyVipNavCtrl.modalPresentationStyle = UIModalPresentationOverFullScreen;
        [self presentViewController:buyVipNavCtrl animated:YES completion:^{
            
        }];
        buyVipCtrl.ApplePayBuyVipBlock = ^{
            
        };
        buyVipCtrl.ApplePayRepeatBuyVipBlock = ^{
            
        };
    }else{
        complick();
    }
}
- (void)homeSet{
    DZMainController * mainCtrl = [[DZMainController alloc] init];
    [self.navigationController pushViewController:mainCtrl animated:YES];
}
- (void)homeSpeedReport{
    DZWeakSelf
    [self checkVipStatus:^{
        DZSpeedReportController * speedReportCtrl = [[DZSpeedReportController alloc] init];
        [weakSelf.navigationController pushViewController:speedReportCtrl animated:YES];
    }];
}
- (void)homeKeTang{
    DZWeakSelf
    [self checkVipStatus:^{
        DZKeTangController * keTangCtrl = [[DZKeTangController alloc] init];
        [weakSelf.navigationController pushViewController:keTangCtrl animated:YES];
    }];
}
- (void)homeRepoprt{
    DZWeakSelf
    [self checkVipStatus:^{
        DZReportController * reportCtrl = [[DZReportController alloc] init];
        [weakSelf.navigationController pushViewController:reportCtrl animated:YES];
    }];
}
- (void)homeRedomNum{
    DZWeakSelf
    [self checkVipStatus:^{
        DZRedomNumController * redomNumCtrl = [[DZRedomNumController alloc] init];
        [weakSelf.navigationController pushViewController:redomNumCtrl animated:YES];
    }];
}
@end
